﻿@model IEnumerable<WeProjectsModel.News>

@{
    ViewBag.Title = "Index";
}

<h2>新闻列表</h2>

<table class="table">
    @foreach (var item in Model.GroupBy(x => x.ProjectID).Select(x => x.First()))
    {
        <tr>
            <td colspan="2" class="active">@Html.DisplayFor(modelItem => item.Project.Title)</td>
        </tr>
        foreach (var item1 in Model.Where(i => i.ProjectID == item.ProjectID))
        {
            <tr>
                <td>@Html.ActionLink(item1.Title, "Details", new { id = item1.ID })</td>
                <td>
                    @Html.ActionLink("Details", "Details", new { id = item1.ID })
                    @if (Roles.IsUserInRole("sysadmin"))
                    {
                        @Html.Raw((item1.isPublish == 0) ? "未发布 " + Html.ActionLink("点此发布", "NewsPublish", new { newsId = item1.ID, pub = 1 }) : "已发布 " + Html.ActionLink("取消发布", "NewsPublish", new { newsId = item.ID, pub = 0 }))
                    }
                </td>
            </tr>
        }
        <tr><td style="border-width:0" colspan="3"></td></tr>
    }
</table>